package lex.fsm;

import java.util.Collections;
import java.util.List;
import java.util.Vector;

public final class StateContext
{
	private State currentState = null;
	private List<State> stateChain = null;

	public StateContext( State startState )
	{
		this.currentState = startState;
		this.stateChain = new Vector<State>();
	}

	public State getCurrentState()
	{
		return currentState;
	}

	public List<State> getStateChain()
	{
		return Collections.unmodifiableList( this.stateChain );
	}

	void setCurrentState( State state )
	{
		currentState = state;
		this.stateChain.add( state );
	}

	public String toString()
	{
		StringBuilder buf = new StringBuilder();
		buf.append( "current: " ).append( this.currentState );
		buf.append( ", chain" ).append( this.stateChain );
		return buf.toString();
	}
}
